package v1

import (
	"gitee.com/liangziyisheng/caas-platform-mc/internal/consts"
	"gitee.com/liangziyisheng/caas-platform-mc/internal/model/do"

	"gitee.com/liangziyisheng/caas-platform-mc/internal/model/entity"

	"github.com/gogf/gf/v2/frame/g"
)

type ListReq struct {
	g.Meta  `path:"/menus" tags:"菜单管理" method:"get" summary:"菜单列表"`
	AppCode string `json:"appCode" v:"required" description:"应用编码" `
}
type ListRes struct {
	g.Meta `mime:"application/json"`
	Data   []*MenusTree `json:"data"`
}

type MenusTree struct {
	Id          int64        `json:"id" description:""`
	AppCode     string       `json:"appCode"`
	Name        string       `json:"name"`
	Description string       `json:"description"`
	Type        int          `json:"type"`
	Path        string       `json:"path"`
	Parent      int64        `json:"parent"`
	Sort        int          `json:"sort"`
	Permissions []*Pms       `json:"permissions"`
	Children    []*MenusTree `json:"children"`
}

type Pms struct {
	Id        int64  `json:"id"`
	Name      string `json:"name"`
	Path      string `json:"path"`
	Operation string `json:"operation"`
	MenuId    int64  `json:"menuId"`
}

type AddReq struct {
	g.Meta      `path:"/menus" tags:"菜单管理" method:"post" summary:"添加菜单"`
	AppCode     string `json:"appCode" v:"required"`
	Name        string `json:"name" v:"required"`
	Description string `json:"description"`
	Type        int    `json:"type" v:"in:2,3" description:"菜单类型: 菜单2页面3按钮9"`
	Path        string `json:"path" v:"required"`
	Parent      int64  `json:"parent" v:"required-unless:type,1"`
	Sort        int    `json:"sort" v:"required|min:1"`
}
type AddRes struct {
	g.Meta `mime:"application/json"`
	Id     int64 `json:"id" description:"菜单Id"`
}

type UpdateReq struct {
	g.Meta      `path:"/menus/{id}" tags:"菜单管理" method:"put" summary:"更新菜单"`
	Id          int64  `query:"id" json:"id" v:"required|min:1" description:"菜单Id"`
	Name        string `json:"name"`
	Description string `json:"description"`
	Path        string `json:"path"`
	Sort        int    `json:"sort"`
}
type UpdateRes struct {
	g.Meta `mime:"application/json"`
	Rows   int64 `json:"rows" description:"修改成功的行数"`
}

type DeleteReq struct {
	g.Meta `path:"/menus/{id}" tags:"菜单管理" method:"delete" summary:"删除菜单"`
	Id     int64 `query:"id" v:"required|min:1"`
}
type DeleteRes struct {
	g.Meta `mime:"application/json"`
	Rows   int64 `json:"rows" description:"删除成功的行数"`
}

type InfoReq struct {
	g.Meta `path:"/menus/{id}" tags:"菜单管理" method:"get" summary:"菜单详情"`
	Id     int64 `query:"id" v:"required|min:1"`
}

type InfoRes struct {
	g.Meta `mime:"application/json"`
}

type AppsReq struct {
	g.Meta `path:"/menus/apps" tags:"菜单管理" method:"get" summary:"应用列表"`
}
type AppsRes struct {
	g.Meta `mime:"application/json"`
	Data   []consts.DdicInfo1 `json:"data" description:"顶级菜单列表"`
}

type TypesReq struct {
	g.Meta `path:"/menus/types" tags:"菜单管理" method:"get" summary:"菜单类型"`
}
type TypesRes struct {
	g.Meta `mime:"application/json"`
	Data   []consts.DdicType1 `json:"data" description:"菜单类型列表"`
}

// input and output structs
type ListInput struct {
	AppCode string `json:"appCode" description:"应用编码" `
}
type ListOutput struct {
	Data []entity.AppMenu `json:"data" description:"菜单列表"`
}

type AppOutput struct {
	Data []entity.AppMenu `json:"data" description:"菜单列表"`
}

type AddInput struct {
	do.AppMenu
}
type AddOutput struct {
	Id int64 `json:"id" description:"新增菜单id"`
}

type UpdateInput struct {
	do.AppMenu
}

type UpdateOutput struct {
	Rows int64 `json:"rows" description:"修改成功的行数"`
}

type DeleteInput struct {
	Id int64 `json:"id"`
}
type DeleteOutput struct {
	Rows int64 `json:"rows" description:"删除成功的行数"`
}

type InfoInput struct {
	Id int64 `json:"id"`
}

type InfoOutput struct {
	Menu entity.AppMenu `json:"menu"`
}
